package natappvip.liujinliang.jedis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import natappvip.liujinliang.util.PropertiesUtil;

/**
 * @ClassName:  JedisConnectionPool   
 * @Despt: Jedis连接池   
 * @Auth: Liujinliang 
 * @Date: 2018年7月29日 下午9:38:19
 */
public class JedisConnectionPool {

	private static JedisPool pool = null;
	
	static {
		pool = new JedisPool(PropertiesUtil.getProperty("redis.ip"),
                Integer.parseInt(PropertiesUtil.getProperty("redis.port")));
	}
	
	public static Jedis getJedis() {
		
		if (pool != null) {
			return pool.getResource();
		} 
		
		return null;
	}
	
	public static void freeJedis(Jedis jedis) {
		
		if(jedis != null) {
			jedis.close();
		}
	}
}
